*cd "/Users/sanchariroy/Google Drive/Sanchari_F/DBW/data/prepared_data/"
cd "/Users/bsog0079/Dropbox/DBW/agencytrainingpaper/ReSTAT_revisions/prepared_data"
*cd "/Users/sr432/Google Drive/Sanchari_F/DBW/data/prepared_data_dropbox/"

use intervention_data, clear

set more off 

/*** This do file contains the code for the following Tables:
Main Tables: 4, 5
Appendix Tables: A7, A8, A12, A14, A15, A16, A17
***/

********************************************************************************
***REGRESSIONS: SAVING PRODUCT CHOICES******************************************
********************************************************************************

forval i=1/8 {

ge cdum`i'=choicedum`i'
replace cdum`i'=0 if choicedum`i'==2|choicedum`i'==3
}

*so, cdum=1 is savings, cdum=0 is fd/mf*

forval i=1/8 {
 
label variable cdum`i' "Session `i'"
}

/**Table 4**/

eststo clear

forval i=1/8 {
 
eststo: reg cdum`i' treat areadum1-areadum2, cl(hhid)
}

esttab using maintables.rtf, append se title(Table 4: Program Impact on Saving Product Choices) cells(b(star fmt(2)) se(par fmt(2))) keep(treat) order(treat) indicate("Area fixed effects = areadum*") label starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))


preserve 

reshape long choice, i(individ) j(session)

ge choicedum=.
replace choicedum=1 if choice=="SAVING"|choice=="SAVINGS"|choice=="SEVING"|choice=="Savind"|choice=="Saving"|choice=="Seving"|choice=="SEVINGS"|choice=="Saving "|choice=="Savings"
replace choicedum=2 if choice=="FD"|choice=="FIXED"|choice=="Fixed"
replace choicedum=3 if choice=="MF"|choice=="FM"

ge cdum=choicedum
replace cdum=0 if choicedum==2|choicedum==3

rename ashamed_bline shame
ge treatshame=treat*shame
label var treatshame "Treatment*Shame in baseline"

ta session, gen(sessiondum)

forval i=1/8 {
ge treatsessiondum`i'=treat*sessiondum`i'
}

/**Table 5**/

eststo clear

eststo reg1: areg cdum treat treatshame shame sessiondum*, absorb(areacode) cl(groupslno)
ritest treat _b[treat], reps(1000) seed(125): `e(cmdline)'
matrix pvalues=r(p)
mat colnames pvalues = treat
est restore reg1

estadd matrix pvalues = pvalues

eststo reg2: areg cdum treat treatushac_bline ushac_bline sessiondum*, absorb(areacode) cl(groupslno)
ritest treat _b[treat], reps(1000) seed(125): `e(cmdline)'
matrix pvalues=r(p)
mat colnames pvalues = treat
est restore reg2

estadd matrix pvalues = pvalues


eststo reg3: areg cdum treat treathasushasav_bline hasushasav_bline sessiondum*, absorb(areacode) cl(groupslno)
ritest treat _b[treat], reps(1000) seed(125): `e(cmdline)'
matrix pvalues=r(p)
mat colnames pvalues = treat
est restore reg3

estadd matrix pvalues = pvalues

esttab using maintables.rtf, append se title(Table 5: Program Impact on Savings Product Choices, by Baseline Shame and Financial Characteristics) cells(b(star fmt(2)) se(par fmt(2)) pvalues(par([ ]))) label keep(treat treatshame shame treatushac_bline ushac_bline treathasushasav_bline hasushasav_bline) order(treat treatshame shame treatushac_bline ushac_bline treathasushasav_bline hasushasav_bline) starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))


/**Appendix Table A8**/

eststo clear

eststo: areg cdum treat, absorb(areacode) cl(groupslno)
eststo: areg cdum treat treatcontrdum2_bline treatcontrdum3_bline contrdum2_bline contrdum3_bline, absorb(areacode) cl(groupslno)
eststo: areg cdum treat treatcontrdum2_bline treatcontrdum3_bline contrdum2_bline contrdum3_bline, absorb(groupslno) cl(groupslno)

esttab using appendtables.rtf, append se title(Appendix Table A8: Program Impact on Savings Product Choices, by Baseline Contracts) cells(b(star fmt(2)) se(par fmt(2))) label keep(treat treatcontrdum2_bline treatcontrdum3_bline contrdum2_bline contrdum3_bline) order(treat treatcontrdum2_bline treatcontrdum3_bline contrdum2_bline contrdum3_bline) starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))


/**Appendix Table A12**/

label var treatsessiondum1 "Treatment*Session 1"
label var treatsessiondum2 "Treatment*Session 2"
label var treatsessiondum3 "Treatment*Session 3"
label var treatsessiondum4 "Treatment*Session 4"
label var treatsessiondum5 "Treatment*Session 5"
label var treatsessiondum6 "Treatment*Session 6"
label var treatsessiondum7 "Treatment*Session 7"
label var treatsessiondum8 "Treatment*Session 8"

label var sessiondum1 "Session 1"
label var sessiondum2 "Session 2"
label var sessiondum3 "Session 3"
label var sessiondum4 "Session 4"
label var sessiondum5 "Session 5"
label var sessiondum6 "Session 6"
label var sessiondum7 "Session 7"
label var sessiondum8 "Session 8"

eststo clear

eststo: reg cdum treatsessiondum1-treatsessiondum8 sessiondum2-sessiondum8 areadum1-areadum2, cl(groupslno)
eststo: areg cdum treatsessiondum2-treatsessiondum8 sessiondum2-sessiondum8, absorb(individ) cl(groupslno)

esttab using appendtables.rtf, append se title(Appendix Table A12: Program Impact on Saving Product Choices, with Individual fixed effects) cells(b(star fmt(2)) se(par fmt(2))) keep(treatsessiondum2 treatsessiondum3 treatsessiondum4 treatsessiondum5 treatsessiondum6 treatsessiondum7 treatsessiondum8 sessiondum2 sessiondum3 sessiondum4 sessiondum5 sessiondum6 sessiondum7 sessiondum8) order(treatsessiondum2 treatsessiondum3 treatsessiondum4 treatsessiondum5 treatsessiondum6 treatsessiondum7 treatsessiondum8 sessiondum2 sessiondum3 sessiondum4 sessiondum5 sessiondum6 sessiondum7 sessiondum8) indicate("Area fixed effects = areadum*") label starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))

restore


/**Appendix Table A7**/

ge treatmuslim_bline=treat*muslim_bline
label var treatmuslim_bline "Treatment*Muslim"

eststo clear

forval i=1/8 {
 
eststo: reg cdum`i' treat treatmuslim_bline muslim_bline areadum1-areadum2, cl(hhid)
}

esttab using appendtables.rtf, append se title(Appendix Table A7: Program Impact on Saving Product Choices, by Baseline Religion) cells(b(star fmt(2)) se(par fmt(2))) keep(treat treatmuslim_bline muslim_bline) order(treat treatmuslim_bline muslim_bline) indicate("Area fixed effects = areadum*") label starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))


/**Appendix Table A14**/

bysort groupslno houseslno: egen womeninhouse=count(areacode)
label var womeninhouse "No. of women in house"

bysort groupslno: egen womeningroup=count(areacode)
label var womeningroup "No. of women in group"

ge propwomeninhouse=womeninhouse/womeningroup

ge treatpropwomeninhouse=treat*propwomeninhouse

label var propwomeninhouse "% of women from same house"
label var treatpropwomeninhouse "Treatment*% of women from same house"


eststo clear

forval i=1/8 {
 
eststo: reg cdum`i' treat treatpropwomeninhouse propwomeninhouse areadum1-areadum2, cl(hhid)
}

esttab using appendtables.rtf, append se title(Appendix Table A14: Program Impact on Saving Product Choices, by Group Composition) cells(b(star fmt(2)) se(par fmt(2))) keep(treat treatpropwomeninhouse propwomeninhouse) order(treat treatpropwomeninhouse propwomeninhouse) indicate("Area fixed effects = areadum*") label starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))


/**Appendix Table A15**/

eststo clear

forval i=1/8 {
 
eststo: reg cdum`i' treat treatmemdurb_bline memdurb_bline areadum1-areadum2, cl(hhid)
}

esttab using appendtables.rtf, append se title(Appendix Table A15: Program Impact on Saving Product Choices, by NGO membership) cells(b(star fmt(2)) se(par fmt(2))) keep(treat treatmemdurb_bline memdurb_bline) order(treat treatmemdurb_bline memdurb_bline) indicate("Area fixed effects = areadum*") label starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))


/**Appendix Table A16**/

eststo clear

forval i=1/8 {

eststo: reg cdum`i' treatarea1-treatarea3 areadum1-areadum2, cl(hhid)
}

esttab using appendtables.rtf, append se title(Appendix Table A16: Program Impact on Saving Product Choices, by Location) cells(b(star fmt(2)) se(par fmt(2))) keep(treatarea1 treatarea2 treatarea3 areadum1 areadum2 _cons) order(treatarea1 treatarea2 treatarea3 areadum1 areadum2 _cons) label starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))


/**Appendix Table A17**/

eststo clear

forval i=1/8 {

eststo: reg cdum`i' treat treatresp_bline resp_bline areadum1-areadum2, cl(hhid)
}

esttab using appendtables.rtf, append se title(Appendix Table A17: Program Impact on Saving Product Choices, by Baseline Need for Social Approval) cells(b(star fmt(2)) se(par fmt(2))) keep(treat treatresp_bline resp_bline) order(treat treatresp_bline resp_bline) indicate("Area fixed effects = areadum*") label starlevels(* 0.10 ** 0.05 *** 0.01) stats(r2_a N, fmt(2 0) label("Adj. R-sq" "N"))














